package com.wondersgroup.fjzlpt.console.dao.impl.yljgxx;

import com.alibaba.fastjson.JSONArray;
import com.quick.framework.boot.repository.sql.bean.SQLBean;
import com.quick.framework.boot.repository.sql.bean.table.TableBean;
import com.quick.framework.boot.repository.sql.jdbcTemplate.impl.BaseJTDAOImpl;
import com.wondersgroup.fjzlpt.console.dao.inter.yljgxx.YljgZyjrDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

/**
 * Created by lion on 2017/8/8.
 */
@Repository
public class YljgZyjrDAOImpl extends BaseJTDAOImpl implements YljgZyjrDAO {

    @Override
    @Autowired
    @Qualifier("TB_ZD_YLJG_ZYJRXX")
    public void setTb(TableBean tb) {
        super.setTb(tb);
    }

    /**
     * 根据平台机构ID查询资源接入信息
     * @param ptjgid
     * @return
     */
    public JSONArray queryByPtjgid(String ptjgid){
        StringBuilder sbud = new StringBuilder(this.tb.getSqlQuery())
                .append(" where 1=1 and PTJGID=?");
        SQLBean sb = new SQLBean(sbud.toString(), new Object[]{ptjgid});
        return this.queryList(sb);
    }

    /**
     * 根据平台机构ID删除配置
     * @param ptjgid
     */
    public void deleteByPtjgid(String ptjgid){
        StringBuilder sbud = new StringBuilder("delete from ").append(this.tb.getTableName())
                .append(" where PTJGID=?");
        SQLBean sb = new SQLBean(sbud.toString(), new Object[]{ptjgid});
        this.update(sb);
    }
}










